import Vue from 'vue'
import Router from 'vue-router'
// in development env not use Lazy Loading,because Lazy Loading too many pages will cause webpack hot update too slow.so only in production use Lazy Loading
/* layout */
import Layout from '../views/layout/Layout'

const _import = require('./_import_' + process.env.NODE_ENV)
Vue.use(Router)
export const constantRouterMap = [
  {path: '/login', component: _import('login/index'), hidden: true},
  {path: '/404', component: _import('404'), hidden: true},
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: '首页',
    hidden: true,
    children: [{
      path: 'dashboard', component: _import('dashboard/index')
    }]
  }
]
export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap
})
export const asyncRouterMap = [
  {
    path: '/ui',
    component: Layout,
    redirect: '/ui/pageModule',
    name: 'functionModule',
    meta: {title: 'WEB测试', icon: 'web'},
    children: [
      {
        path: 'statistics',
        name: 'statistics',
        component: _import('ui/statistics/index'),
        meta: {title: '统计图表', icon: ''},
        menu: 'statistics'
      },
      {
        path: 'project',
        name: 'project',
        component: _import('ui/project/index'),
        meta: {title: '项目管理', icon: ''},
        menu: 'project'
      },
      {
        path: 'pageModule',
        name: 'pageModule',
        component: _import('ui/pageModule/index'),
        meta: {title: '元素管理', icon: ''},
        menu: 'pageModule'
      },
      {
        path: 'scene',
        name: 'scene',
        component: _import('ui/scene/index'),
        meta: {title: '用例管理', icon: ''},
        menu: 'scene'
      },
      {
        path: 'cuView',
        name: 'cuView',
        component: _import('ui/scene/cuView'),
        hidden: true,
        meta: {title: '用例管理', icon: ''},
        menu: 'scene'
      },
      {
        path: 'plan',
        name: 'plan',
        component: _import('ui/plan/index'),
        meta: {title: '执行计划', icon: ''},
        menu: 'plan'
      },
      {
        path: 'planCu',
        name: 'planCu',
        component: _import('ui/plan/cuView'),
        hidden: true,
        meta: {title: '执行计划', icon: ''},
        menu: 'plan'
      },
      {
        path: 'report',
        name: 'report',
        component: _import('ui/report/index'),
        meta: {title: '测试报告', icon: ''},
        menu: 'report'
      },
    ]
  },
  {
    path: '/testTool',
    component: Layout,
    redirect: '/testTool/dataSource',
    name: 'testTool',
    meta: {title: '测试工具', icon: 'tool'},
    children: [
      {
        path: 'dataSource',
        name: 'dataSource',
        component: _import('testTools/dataSource/index'),
        meta: {title: '数据生成', icon: ''},
        menu: 'dataSource'
      },
      {
        path: 'dataGenerate',
        name: 'dataGenerate',
        component: _import('testTools/dataGenerate/index'),
        meta: {title: '数据生成', icon: ''},
        hidden: true,
        menu: 'dataGenerate'
      },
      {
        path: 'caseGenerate',
        name: 'caseGenerate',
        component: _import('testTools/caseGenerate/index'),
        meta: {title: '用例生成', icon: ''},
        hidden: false,
        menu: 'caseGenerate'
      },
      {
        path: 'fileManage',
        name: 'fileManage',
        component: _import('testTools/fileManage/index'),
        meta: {title: '文件管理', icon: ''},
        menu: 'fileManage'
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    redirect: '/user/',
    name: '用户权限',
    meta: {title: '系统管理', icon: 'system'},
    children: [
      // {
      //   path: 'project',
      //   name: 'project',
      //   component: _import('system/project/index'),
      //   meta: {title: '项目管理', icon: ''},
      //   menu: 'project'
      // },
      {
        path: '',
        name: '用户列表',
        component: _import('system/user/user'),
        meta: {title: '用户管理', icon: ''},
        menu: 'user'
      },
      {
        path: 'role',
        name: '角色管理',
        component: _import('system/user/role'),
        meta: {title: '角色管理', icon: 'password'},
        menu: 'role'
      },
      {
        path: 'dingTalkConfig',
        name: 'dingTalkConfig',
        component: _import('system/dingTalkConfig/index'),
        meta: {title: '钉配置管理', icon: ''},
        menu: 'dingTalkConfig'
      },
    ]
  },
  {path: '*', redirect: '/404', hidden: true}
]
